//#define LED_MODULE 

//#include <string.h>
//#include <stdio.h>
//#include <stdlib.h>
//#include <unistd.h>
//#include <pthread.h>
//#include <fcntl.h>   //define O_WRONLY and O_RDONLY
#include <jni.h>
#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <signal.h>
#include <semaphore.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>

#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif


#define LED_FILEPATH   "/dev/csigpio"        //LED

#if 0
int main(int argc, char *argv[])
{

	int fd;
	int state = 0;
	int cmd = 0;
	int arg = 0;
	char value_str[3] = {0};
	
	fd = open(LED_FILEPATH, O_RDWR);
    if (fd < 0)
    {
        printf("open Dev /dev/gpioled Error!\n");
        return -1;
    }
	
	cmd = atoi(argv[1]);
	printf("%d\n", cmd);
	if (ioctl(fd, cmd, arg) < 0) {
		printf("ioctl fail\n");
		return -1;
	}
	
	close(fd);

    return 0;
}
#endif


int main(int argc, char *argv[])
{

	int fd;
	int state = 0;
	int cmd = 3;
	int arg = 3;
	
	fd = open(LED_FILEPATH, O_RDWR);
    if (fd < 0)
    {
        printf("open Dev /dev/gpioled Error!\n");
        return -1;
    }
	
	printf("%d\n", cmd);
	if (ioctl(fd, cmd, arg) < 0) {
		printf("ioctl fail\n");
		return -1;
	}
	
	int ret = 0;
	
	cmd = 6;
	while (1) {	
		if ((ret = ioctl(fd, cmd, arg)) < 0) {
			printf("ioctl fail\n");
			return -1;
		}
		
		printf("ret = %d\n", ret);
		//sleep(2000);
		//sleep(2);
		usleep(300000);
	}
	
	close(fd);

    return 0;
}















